package com.jiangroom.service;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName RabbitCustomer
 * @Description TODO
 * @Author chen.pian
 * @Date 2019/8/16 10:11
 **/
@Component
public class RabbitCustomer {
    @Autowired
    private AmqpTemplate rabbitmqTemplate;

    /**
     * 消息消费
     *
     * @RabbitHandler 代表此方法为接受到消息后的处理方法
     */
    @RabbitListener(queues = "test.d")
    public void recieved(Message msg) {
        System.out.println("[string] recieved message:" + new String(msg.getBody()));
    }
}
